<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>

        <ui:composition template="./../templates/default3.xhtml">
            <ui:define name="content">
                <h:form id="addSupplier" binding="#{supplierManagerBean.loadAddSupplier}">
                    <p:messages id ="error"/>
                    <p:panel header="Supplier Information" id="addSupplier">
                        <font class="fieldNote">* - Mandatory Field<br/><br/></font> 
                        <table>                            
                            <tr>
                                <td>Supplier Id:</td>
                                <td width="200px"> 
                                    <p:inputText required="true" id="supplierId" requiredMessage="Supplier Id Required" value="#{supplierManagerBean.supplierId}">
                                    </p:inputText>
                                    <font class="fieldNote">*</font>
                                  
                                </td>
                                
                                <td width="80px">Company:</td>
                                <td> 
                                    <p:inputText required="true" id="company" requiredMessage="Company Required" value="#{supplierManagerBean.company}" >
                                    </p:inputText> 
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>      
                            <tr>
                                <td>Name:</td>
                                 <td> 
                                    <p:inputText required="true" id="name" requiredMessage="Name Required" value="#{supplierManagerBean.name}" >
                                    </p:inputText> 
                                    <font class="fieldNote">*</font>
                                </td>
                                <td>Ranking:</td>
                                <td>                                                                                
                                     <h:selectOneMenu id="ranking" value="#{supplierManagerBean.ranking}">
                                        <f:selectItem id="Poor" itemLabel="Poor" itemValue="Poor" />
                                        <f:selectItem id="Moderate" itemLabel="Moderate" itemValue="Moderate" />
                                        <f:selectItem id="Reliable" itemLabel="Reliable" itemValue="Reliable" />         
                                    </h:selectOneMenu>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                 <td>Contact:</td>
                                <td>                                                                                
                                    <p:inputText label="contact" required="true" id="contact" requiredMessage="Contact Required" value="#{supplierManagerBean.contact}" validatorMessage="Contact Must Have a Minimum of 8 Digits">
                                        <f:validateLength minimum="8"/>
                                    </p:inputText>
                                    <font class="fieldNote">* Min. 8</font>
                                </td>
                                <td>Email:</td>
                                <td>
                                      <p:inputText required="true" id="email" requiredMessage="Email Required" value="#{supplierManagerBean.email}" validatorMessage="Invalid Email Address Format">
                                        <f:validateRegex pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$" />
                                    </p:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>     
                            <tr>
                                 <td width ="80px" valign="top"> Comment:</td>
                                <td width="200px" valign="top"> 
                                    <p:inputTextarea id="comment" style="width:160px;height:80px;" maxHeight="80" effectDuration="400" value="#{supplierManagerBean.comment}">

                                    </p:inputTextarea>   
                                </td>
                            </tr>            
                        </table>
                    </p:panel>
                    <p:panel header="Company Address" id="addSupplier2">
                        <table>
                            <tr>
                                <td width ="80px" valign="top" > Street:</td>
                                <td width="205px" valign="top"> 
                                    <table><tr><td><p:inputTextarea id="street" required="true" requiredMessage="Street Required" style="width:160px;height:60px;" maxHeight="60" effectDuration="400" value="#{supplierManagerBean.street}">
                                                </p:inputTextarea></td><td> <font class="fieldNote">*</font></td></tr></table>

                                </td>
                                <td width="80px">City: <br/><br/> Country: </td>
                                <td width="200px">
                                    <p:inputText  required="true" requiredMessage="City Required" id="city" value="#{supplierManagerBean.city}">
                                    </p:inputText>
                                    <font class="fieldNote">*</font>
                                    <br/><br/>
                                    <p:inputText required="true" requiredMessage="Country Required" id="country" value="#{supplierManagerBean.country}">
                                    </p:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td valign ="top" >Postal: </td>
                                <td width="200px" valign ="top"> 
                                    <p:inputText label="Postal" required="true" requiredMessage="Postal Required" id="postal" value="#{supplierManagerBean.postal}" validatorMessage="Postal Code Must Have a Minimum of 4 Digits and Maximum of 8 Digits">
                                        <f:validateLength minimum="4" maximum="11"/>
                                    </p:inputText>
                                    <font class="fieldNote">* Min. 4 , Max. 11</font> 
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                    
                  
                    <table class="panel">
                        <tr>
                            <td  class="btn" ><hr/>
                                <p:commandButton id="btnAddSupplier" value="Create Supplier" actionListener="#{supplierManagerBean.addASupplier}" update="error" ajax="true" />
                            </td>
                        </tr>
                    </table>
                </h:form>
            </ui:define>   
        </ui:composition>

    </body>
</html>
